package com.eveinfo.api.balance;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import com.eveinfo.api.AbstractApiParser;
import com.eveinfo.api.ApiAuth;
import com.eveinfo.api.ApiException;
import com.eveinfo.api.NoCacheFoundExecption;

public class AccountBalanceParser extends AbstractApiParser<AccountBalanceResponse, AccountBalanceHandler> {
	protected static final String ACCOUNTBALANCE_URL = "/AccountBalance.xml.aspx";

	private static AccountBalanceParser instance;

	public static AccountBalanceParser getInstance() {
		if (instance == null) {
			instance = new AccountBalanceParser();
		}
		return instance;
	}

	private AccountBalanceParser() {
		super(AccountBalanceResponse.class, 1, ACCOUNTBALANCE_URL);
	}

	public AccountBalanceResponse getAccountBalance(ApiAuth auth, boolean corporation) throws IOException,
			SAXException, ParserConfigurationException, ApiException, NoCacheFoundExecption {
		AccountBalanceHandler handler = new AccountBalanceHandler();
		if (corporation)
			return getResponse(auth, Path.CORP, handler);
		return getResponse(auth, Path.CHARACTER, handler);
	}

	public static boolean isInstancier() {
		return instance != null;
	}

}